package com.component.api.model;


import lombok.NoArgsConstructor;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

/**
 * 描述：
 * 流程结果返回类
 * @author xianggj
 * @Date 2021/10/12 16:24
 **/
@NoArgsConstructor
public class ProcessResult implements Serializable {

    private static final long serialVersionUID = -1L;

    public ProcessResult(String flowId, String nodeId) {
        this.nodeId = nodeId;
        this.flowId = flowId;
    }

    private String flowId;

    private String nodeId;

    public String getNodeId() {
        return nodeId;
    }

    public void setNodeId(String nodeId) {
        this.nodeId = nodeId;
    }

    public String getFlowId() {
        return flowId;
    }

    public void setFlowId(String flowId) {
        this.flowId = flowId;
    }

    /**
     * 端口： 值 因为没有端口
     * 端口有顺序
     */
    private Map<String, AbstractData> outputDatas = new LinkedHashMap<>();

    public Map<String, AbstractData> getOutputDatas() {
        return outputDatas;
    }

    public void setOutputDatas(Map<String, AbstractData> outputDatas) {
        this.outputDatas = outputDatas;
    }

    public void addAbstractTableData(String portName, AbstractData data) {
        outputDatas.put(portName, data);
    }

    /**
     * 返回参数格式
     * @return
     */
    public List<PortData> getPortDatas(){
        List<PortData> list = new ArrayList<>();
        for (Map.Entry<String, AbstractData> entry : outputDatas.entrySet()) {
            list.add(new PortData(nodeId, entry.getKey(), entry.getValue()));
        }
        return list;
    }
}
